"use strict";
cc._RF.push(module, 'ee248WruIJGAaZle35NdH5g', 'user_bankcardUnbind_pop');
// scripts/user/user_bankcardUnbind_pop.js

"use strict";

// Learn cc.Class:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/class.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/class/index.html
// Learn Attribute:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/reference/attributes.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/reference/attributes/index.html
// Learn life-cycle callbacks:
//  - [Chinese] http://www.cocos.com/docs/creator/scripting/life-cycle-callbacks.html
//  - [English] http://www.cocos2d-x.org/docs/editors_and_tools/creator-chapters/scripting/life-cycle-callbacks/index.html

cc.Class({
    extends: cc.Component,

    properties: {
        labLastBankNum: cc.Label, //银行卡后四位
        labBankName: cc.Label, //银行卡名
        _data: null,
        bankCode: "",
        callBack: null //回调   

    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start: function start() {
        if (this._data != null) {
            this.labLastBankNum.string = this._data.last;
            this.labBankName.string = this._data.bankname;
            this.bankCode = this._data.bankcode;
        }
    },


    init: function init(ret, callback) {
        this._data = ret;
        this.callBack = callback;
    },

    onTrue: function onTrue() {
        var recv = function (ret) {
            ComponentsUtils.unblock();
            if (ret.Code != 0 && ret.Code != 49) {
                ComponentsUtils.showTips(ret.Msg);
                cc.error(ret.Msg);
            } else {
                ComponentsUtils.showTips("解绑成功！");
                this.callBack("");
                this.onClose();
            }
        }.bind(this);

        var data = {
            Token: User.getLoginToken(),
            UserCode: User.getUserCode(),
            BankCode: this.bankCode
        };
        CL.HTTP.sendRequestRet(DEFINE.HTTP_MESSAGE.UNBINDBANKCARD, data, recv.bind(this), "POST");
        ComponentsUtils.block();
    },

    onClose: function onClose() {
        this.node.getComponent("Page").backAndRemove();
    }

    // update (dt) {},
});

cc._RF.pop();